# coding: utf-8
from typing import Union

from PyQt6.QtGui import QIcon
from PyQt6.QtWidgets import QWidget
from qfluentwidgets import GroupHeaderCardWidget, FluentIconBase, CardGroupWidget


class OptimizeGroupHeaderCardWidget(GroupHeaderCardWidget):
    def addGroup(
            self,
            icon: Union[str, FluentIconBase, QIcon],
            title: str = "",
            content: str = "",
            widget: QWidget = None,
            stretch=0
    ) -> CardGroupWidget:
        group = super().addGroup(icon, title, content, widget, stretch)
        if not content:
            group.contentLabel.setVisible(False)
        if not widget:
            group.setParent(self)
        return group
